/*
 * Copyright (c) 2005 -2008 Reliable Source, Inc. and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Mozilla Public License v.1.1,
 * BSD, and Eclipse Public License v1.0 which accompanies this
 * distribution and is available at:
 *
 * 		http://www.eclipse.org/legal/epl-v10.html
 * 		http://www.opensource.org/licenses/bsd-license.php
 * 		http://www.mozilla.org/MPL/MPL-1.1.html
 *
 * Contributors:
 *     IBM Corporation	     -  http://ibm.com
 *     	- initial API and implementation
 *
 *     patientos.org         - http://patientos.org
 *     	- domain and database persistence layer
 *
 *     Reliable Source, Inc. - http://reliablesource.org
 *     	- Symbiosys Application Framework,
 *     	- Symbiosys Application, Symbiosys Product
 *
 */
package org.reliablesource.symbiosys.ui.tests.dialogs;

import junit.framework.TestCase;

import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.jface.resource.ImageDescriptor;

import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Shell;

import org.eclipse.ui.plugin.AbstractUIPlugin;


/**
 *
 * TitleAreaDialogTest.java<br>
 * Created on: Jun 27, 2008<br>
 *
 * @author <a href="mailto:dennis.park@gmail.com">Dennis Park</a>
 *
 * @category
 * @since 1.0
 */
public class TitleAreaDialogTest extends TestCase {
    static ImageDescriptor descriptor = AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.ui.tests",
            "icons/anything.gif");

    // Test setting the title image before creating the dialog.
    public void testSetTitleImageEarly() {
        final TitleAreaDialog dialog = new TitleAreaDialog(null);
        dialog.setBlockOnOpen(false);

        final Image image = descriptor.createImage();
        dialog.setTitleImage(image);
        dialog.create();

        Shell shell = dialog.getShell();
        shell.addDisposeListener(new DisposeListener() {
                public void widgetDisposed(DisposeEvent e) {
                    image.dispose();
                }
            });
        dialog.open();
    }

    public void testSetTitleImageNull() {
        TitleAreaDialog dialog = new TitleAreaDialog(null);
        dialog.setBlockOnOpen(false);
        dialog.setTitleImage(null);
        dialog.open();
        dialog.setTitleImage(null);
    }
}
